<template>
	<view class="">
		<!-- #ifdef APP-PLUS -->
		<!-- <view class="topPlace"></view> -->
		<!-- #endif -->
		<view class="exchange_bg">
			<view class="jui_bg_fff jui_lrtop box">
				<view
					class="jui_bor_bottom jui_pad_b20  jui_pad_20  jui_flex jui_flex_justify_between jui_flex_items_baseline"
					:class="{'jui_bg_f5f':index%2==0}" v-for="(item,index) in list" :key="index" @tap="goTask(item)">
					<view class="">
						<view class="jui_fc_333 jui_fs30 fw-w x-f">
							<image :src="item.logo||'/static/logo.png'" class="w40r h40r mr20r" mode="aspectFit">
							</image>
							<text>{{item.symbol_name}}</text>
						</view>
						<view class="jui_fc_999  jui_fs28" style="white-space:nowrap;">24H{{i18n.liang}}{{item.vol||'0'}}</view>
					</view>
					<view class=" jui_fc_333 tc">
						<view class="jui_fc_333 jui_fs30 fw-w">{{item.last_price}}</view>
						<view class="jui_fc_999 jui_fs28">≈{{item.cny}}cny</view>
					</view>
					<view class="bg_btn jui_font_weight" v-if="item.percent > 0">
						{{item.percent?item.percent:0.00}}%
					</view>
					<view class="bg_btn- jui_font_weight" v-else>
						{{item.percent?item.percent:0.00}}%
					</view>
				</view>
				<shopro-empty v-if="!list.length" :emptyData="emptyData"></shopro-empty>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				keywords: '',
				FromToken: '',
				page: 1,
				size: 20,
				id: '', //平台id,
				hasMore: false,
				emptyData: {
					img: '/static/imgs/home/empty_goods.png',
					tip: '暂无数据'
				},
				tab: [{
						text: '待确认'
					},
					{
						text: '成功'
					},
					{
						text: '失败'
					},
				],
				tabIndex: 0,
				image: ''
			}
		},
		onLoad(opt) {
			this.id = opt.id;
			this.image = opt.image
		},
		onShow() {
			this.getBi()
			// this.getFromToken()
		},
		onReachBottom() {
			if (this.hasMore) {
				this.page++;
				this.getBi();
			}
		},
		onNavigationBarSearchInputConfirmed(e) {
			// console.log(e)
			let data = {
				id: this.id,
				keywords: e.text
			}
			this.$api.getSymbolByKeywords(data).then(res => {
				if (res.code == 1) {
					this.list = res.data
				}
			});
		},
		methods: {
			getFromToken() {
				this.$api.getFromToken({
					data: 1
				}).then(res => {
					if (res.code == 1) {
						this.FromToken = res.FromToken;
						this.getBi()
					}
				});
			},
			getBi() {
				let data = {
					FromToken: this.FromToken,
					page: this.page,
					size: this.size,
					id: this.id
				}
				this.$api.getSymbolByHouseID(data).then(res => {
					if (this.page == 1) {
						this.list = res.data.data
					} else {
						this.list = [...this.list, ...res.data.data]
					}
					if (res.data.data.length == 0) {
						this.hasMore = false
					} else {
						this.hasMore = true
					}

				});
			},
			onSearch() {
				let data = {
					id: this.id,
					keywords: this.keywords
				}
				this.$api.getSymbolByKeywords(data).then(res => {
					if (res.code == 1) {
						this.list = res.data
					}
				});
			},
			back() {
				uni.navigateBack()
			},
			goTask(item) {
				uni.navigateTo({
					url: `/pages/task/newTask/newTask?name=${item.symbol}&exchange_house_id=${this.id}&image=${this.image}&symbol_name=${item.symbol_name}`
				})
			},
			chooseTab(item, index) {
				// this.page = 1,
				this.tabIndex = index;
				// this.staus = index + 1;
				// this.list = [];
				// this.log()
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.exchange_bg {
		background: $zhuse;
		padding-top: 90rpx;
		/*  #ifndef H5 */
		padding-top: 190rpx;

		/* #endif */
		.box {
			flex-wrap: wrap;
		}
	}

	.on {
		width: 38rpx;
		height: 8rpx;
		background: $zhuse;
		border-radius: 4rpx;
	}

	.topPlace {
		width: 100%;
		height: var(--status-bar-height);
		background: $zhuse;

	}

	.top {
		width: 100%;
		padding: 14upx 0upx;
		background: $zhuse;
		// #ifdef MP-WEIXIN
		padding-top: 50upx;
		// padding-right: 28%;
		// #endif
	}

	.search {
		width: 95%;
		margin: 0 auto !important;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.l {
			flex: 1;
			margin-left: 20upx;
			border-radius: 30upx;
			padding: 0 30upx;
			height: 70upx;
			background: rgba(255, 255, 255, 0.1);
			display: flex;
			align-items: center;

			image {
				width: 28upx;
				height: 28upx;
			}

			text {
				font-size: 26upx;
				color: #fff;
				margin-left: 10upx;
			}

			input {
				height: 100%;
				color: #fff;
				font-size: 26upx;
				margin-left: 10upx;
				flex: 1;
			}

			.input-placeholder,
			.pl-input {
				color: #fff;
			}
		}

	}

	.bg_btn- {
		background-color: $col-red;
		padding: 10rpx 20rpx;
		border-radius: 8rpx;
		color: #FFFFFF;
		min-width: 150rpx;
		text-align: center;
	}

	.bg_btn {
		background-color: $col-green;
		padding: 10rpx 20rpx;
		border-radius: 8rpx;
		color: #FFFFFF;
		min-width: 150rpx;
		text-align: center;
	}
</style>
